<?php

if($_POST && $_POST['act'] && $_POST['act']=='submit'){
    if(!empty($_POST['insurance_fee'])){
        $inStr = '';
        foreach ($_POST['insurance_fee'] as $k=>$v)
        {
            $tax_price_low = $_POST['tax_price_low'][$k];
            $tax_price_high = $_POST['tax_price_high'][$k];
            if(empty($inStr)){
                $inStr .= "('".$tax_price_low."','".$tax_price_high."','".$v."','".$_SESSION['ADMIN_USER']."')";
            }else{
                $inStr .= ",('".$tax_price_low."','".$tax_price_high."','".$v."','".$_SESSION['ADMIN_USER']."')";
            }
        }
        
        if(!empty($inStr)){
            //先清空之前的
            $sql = "delete from haiou_tax_insurance_fee";
            $db->query($sql);
            
            //插入
            $sql = "insert into haiou_tax_insurance_fee (`tax_price_low`,`tax_price_high`,`insurance_fee`,`create_user`) values {$inStr}";
            $db->query($sql);
        }
    }
}

$sql = "select * from haiou_tax_insurance_fee order by tax_price_low";
$db->query($sql);
$de = $db->getRows();
$tpl->assign("de",$de);
$tpl->assign("config",$config);
$tpl->display("tax_insurance_fee_setting.html");
?>